package rainingcatsdogs;

import javax.microedition.lcdui.Image;

/**
 * The Bonus class which holds a bonus enemy that is moving from left to right
 * in the screen
 * 
 * @author Rob
 * 
 */
public class Bonus extends MovableObject {

	/**
	 * This is the health that the bonus enemy unit currently has.
	 */
	private int health;

	/**
	 * Construct the bonus enemy object based on an image and a given health.
	 * 
	 * @param explodeFrames
	 *            The number of frames it takes for the bonus enemy to explode,
	 *            once destroyed.
	 * @param image
	 *            The image of the bonus enemy to use.
	 * @param frameWidth
	 *            The width of one frame of the image.
	 * @param frameHeight
	 *            The height of one frame of the image.
	 * @param health
	 *            The health points of the bonus enemy.
	 */
	public Bonus(int explodeFrames, Image image, int frameWidth,
			int frameHeight, int health) {
		super(explodeFrames, image, frameWidth, frameHeight);
		this.health = health;
	}

	/**
	 * This reduces the current health of the bonus enemy: if the health drops
	 * below 1 then the bonus enemy is destroyed.
	 * 
	 * @param damage
	 *            The amount of damage the bonus enemy should be taking.
	 * @return Whether the bonus enemy is destroyed.
	 */
	public boolean reduceHealth(int damage) {
		this.health -= damage;
		if (this.health < 1) {
			this.destroy();
			return true;
		} else {
			return false;
		}
	}
}
